<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app"></div>
</body>
<script src="../js/react.development.js"></script>
<script src="../js/react-dom.development.js"></script>
<script src="../js/babel.min.js"></script>
<script type="text/babel">
    // 定义类式组件
    class MyComponent extends React.Component {
        // 给自定义组件添加构造器方法
        constructor(props) {
            // 添加super
            super(props)
            // 初始化state
            this.state = {
                isHot: false
            }
        }
        render() {
            // 从状态中读取isHot属性
            const { isHot } = this.state
            // 根据属性值判断显示是否炎热
            return <h2>今天的天气很{isHot ? '炎热' : '凉爽'} </h2>
        }
    }
    ReactDOM.render(<MyComponent/>,document.getElementById("app"))
</script>

</html>